package gdut.imis.controller;

import gdut.imis.Utils.Result;
import gdut.imis.domain.College;
import gdut.imis.service.CollegeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * @Description
 * @Author JiaFu
 * @Date 2023/4/7 15:38
 */
@RestController
@RequestMapping("/college")
@Api(value = "大学学院档案接口", tags = {"大学学院档案接口"})
@RequiredArgsConstructor
public class CollegeController extends BaseController {
    private final CollegeService collegeService;

    @ApiOperation("大学学院档案录入（需要由college权限）")
    @PostMapping("/addCollege")
    @PreAuthorize("@cp.hasPermission('college')")
    public Result add(@RequestBody College college) {
        return collegeService.addCollege(college);
    }

    @ApiOperation("获取大学学院档案列表")
    @GetMapping("/getCollegeList")
    public Result get() {
        return collegeService.getCollegeList();
    }

    @ApiOperation("根据大学id查询学院列表")
    @GetMapping("/getCollegeListByUniversityId/{universityId}")
    public Result getCollegeListByUniversityId(@PathVariable("universityId") Long universityId){
        return collegeService.getCollegeListByUniversityId(universityId);
    }
}
